<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<title></title>
		<script type="text/javascript" src="script/config.js"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			body{
      	background-color:white;
      }
			.box {
				height: 100%;
				width: 100%;
				background-color: white;
			}

			.top {
				height: 50px;
				width: 100%;
				margin-top: 80px;
				text-align: center;
				font: 20px "微软雅黑";
				color: rgb(17,64,108);
			}

			.center {
				height: 230px;
				width: 100%;
				text-align: center;
			}

			.center2 {
				height: 32px;
				margin-top: 40px;
				/*line-height: 50px;*/
				text-align: center;
				width: 70%;
				color: #f16c3c;
				margin-left:15%;
				border-bottom:1px solid #f16c3c;
			}
			.mobile_a{
				height:30px;
				vertical-align:top;
				float:left;
				margin-left: 20px;
			}
			.password_a{
				height:30px;
				vertical-align:top;
				float:left;
				margin-left: 20px;
			}
			 ::-webkit-input-placeholder {
				/* WebKit browsers */
				color: rgb(138, 171, 202);
				font-size:18px;
			}
			.center2 input{
				height:32px;
				width:65%;
				border:none;
				list-style: none;
				outline-style: none;
				border: none;
				background: none;
				display: inline-block;
				float: left;
				/*margin-left: 10px;*/
				font-size:18px;
			}
			#password{
				margin-left:10px;
			}
			#mobile{
				margin-left:20px;
			}
			#password_s{
				margin-left:10px;
			}
			.foot{
				width:64%;
				margin-left:18%;
				height:44px;
				background-color:#f16c3c;
				line-height:44px;
				text-align: center;
				color:white;
				font-size:20px;
				border-radius: 10px;
			}
			#kong{
				width:30px;
				height:30px;
				vertical-align:top;
				float:left;
			}
			input {
				-webkit-tap-highlight-color:transparent;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="top">第2步:请输入您的新密码</div>
			<div class="center">
				<!-- <div class="center2">
					<img src="image/mobile.png" class="mobile_a"><input type="text" id="mobile" class="center2_1" placeholder="手机号">
				</div> -->
				<div class="center2">
					<img src="image/password.png" class="password_a"><input type="password" id="password" class="center2_1" placeholder="密码(6~20位)">
				</div>
				<div class="center2">
					<img src="image/password.png" class="password_a"><input type="password" class="center2_1" placeholder="确认密码" id="password_s" style="margin-left=28px;">
				</div>
			</div>
			<div class="foot">下一步</div>
		</div>
	</body>
	<script type="text/javascript" src="script/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="script/local.js"></script>
	<script type="text/javascript" src="script/APICloud-rest.js"></script>
	<script type="text/javascript" src="script/api.js"></script>
	<!-- <script type="text/javascript" src="../script/up_check.js"></script> -->
	<script>
	apiready = function(){
  $api.val($api.dom('#password'),'');
	$api.val($api.dom('#password_s'),'');
	$api.addEvt($api.dom('.foot'), 'click',function(){
		var user = $api.getStorage('user');
		if(user){
			var lorryid=user.lorryid;
			var time=user.time;
			check(lorryid,time);
		}
        var name=api.pageParam.name;
        var mobile=api.pageParam.mobile;
        var idcard=api.pageParam.idcard;
        var password=$api.val($api.dom("#password"));
        var password_s=$api.val($api.dom("#password_s"));
if((!(/^[0-9a-zA-Z_]{1,}$/).test(password))||password.length==0){
					api.toast({
						 msg: '密码为字母或数字',
						 duration: 1000,
						location: 'middle'
					});
				}else if((!(/^[0-9a-zA-Z_]{1,}$/).test(password_s))||password_s.length==0){
					api.toast({
						 msg: '确认密码为字母或数字',
						 duration: 1000,
						location: 'middle'
					});
										}else if(password.length<6||password.length>20){
												api.toast({
													 msg: '密码为6~20位',
													 duration: 1000,
													location: 'middle'
												});
										}else if(password_s!=password){
												api.toast({
													 msg: '两次密码输入不一致',
													 duration: 1000,
													location: 'middle'
												});
										}else{

											$api.post(url+'app.php/changpass',{
														body:{telephone:mobile,
                                  idcard:idcard,
                                  name:name,
																		 password:password,}
													 },function(ret){
														if(ret.result==0){
															api.toast({
																 msg: '成功',
																 duration: 1000,
																location: 'middle'
															});
															// api.openFrame({
															//   url: './firstregister2.html?lorryid='+ret.lorryid,
															//  });
															setTimeout("api.closeWin({name:'password_first'})",550);
															 api.openWin({
																 name: 'index',
																 url:  'index.html',
																  slidBackEnabled:false,
																 pageParam: {
																	 telephone:mobile,
																 }
															 });
														 }else{
															 alert(ret.desc);
														 }
													 });
												 }
												 })
            }
						var check=function(id,time){
						  $api.post(url+'app.php/check',{
						        body:{lorryid:id,
						              time:time,}
						       },function(ret){
						        if(ret.result==4){
						          alert(ret.desc);
						          api.openWin({
						            name: 'index',
						            url:  'index.html',
						          });
						           setTimeout("api.closeWin({name:'main'})",650);
						           $api.rmStorage('password');
						           var key = 'user';
						           var user = {};
						           var aa=$api.getStorage(key);
						           user.lorryid=aa.lorryid;
						            user.telephone=aa.telephone;
						           user.flag= aa.flag
						           user.pass= '';
						           $api.setStorage(key, user);
						           api.alert({
						             title: '提示消息',
						             msg: ret.desc,
						             buttons: ['确定']
						           });
						         }else{
						          //  alert(ret.desc);
						         }
						       });
						}
	</script>
</html>
